let logger = require('log4js').getLogger('mongoose');
let dbPath = require('../config/config.json').DbPath;
// var dbPath =  process.env.MONGOLAB_URI;
let mongoose = require('mongoose');
mongoose.Promise = global.Promise;
// use custom mongodb url or localhost
let db =mongoose.createConnection(dbPath || "mongodb://localhost:27017/mySite");
//let db = mongoose.connection;
db.on('error', function (err) {
  logger.error('连接mongodb数据出错!');
  process.exit(1);
});

module.exports = {
  'base' : mongoose,
  'mongoose': db,
  'Schema': mongoose.Schema
};

